prices = [7, 1, 5, 3, 6, 4]

# 截止到当前历史最低值
# 截止到当前最大利润

min_price = prices[0]
max_money = 0

for i in range(len(prices)):
    min_price = min(prices[i], min_price)
    max_money = max(prices[i] - min_price, max_money)

print(max_money)
